﻿@using XiaoYuStock.Model
@using XiaoYuStock.Model.Models
@using XiaoYuStock.Model.Request
@using XiaoYuStock.WebApp.Controls
@model PagedList<DayData>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section PageSpecificStyleSheetIncludes{

}
<div class="row-fluid">
    <div class="span10">
        @using (Html.BeginForm(null,null, null, FormMethod.Get, new { id = "search", @class = "form-inline" }))
        {
            <div class="dataTables_filter">
              <label><button type="button" class="btn" id="btnUpdate">更新 <i class="icon-check"></i></button></label>
              <label><button type="submit" class="btn" id="btnSearch">搜索 <i class="icon-search"></i></button></label>
                <label><span>模式：</span><select style="width:80px;" name="IsBuy" id="IsBuy"><option selected="selected">不限</option> <option value="1">买盘</option><option value="0">卖盘</option></select></label>
                <label>
                    <span>起始日期：</span>
                    @Html.TextBox("BeginDate", null, new { @class = "m-wrap small" })--@Html.TextBox("EndDate", null, new { @class = "m-wrap small" })
                </label>
                <label>
                    <span>股票代码：</span>
                    @Html.TextBox("ShareCode", null, new { @class = "m-wrap small" })
                </label>
               
            </div>
        }
    </div>
</div>

@using (Html.BeginForm("Delete", "Customer", FormMethod.Post, new { id = "mainForm" }))
{
    <table class="table table-striped table-hover " id="tableHistory">
        <thead>
            <tr>
                <th>
                    股票代码
                </th>
                <th>
                    日期
                </th>
                <th>成交时间</th>
                <th>
                    成交价
                </th>
                <th>
                    成交量
                </th>
                <th>
                    成交额
                </th>
                <th>
                    价格变动
                </th>
    
            </tr>
        </thead>
        <tbody>
            @foreach (var p in Model)
            {
                <tr>
                    <td class="blue">
                        <span title="@p.ShareCode"> @p.ShareCode</span>
                    </td>
                    <td>
                        <span>@p.CurrentDate.ToString("yyyy-MM-dd")</span>
                    </td>
                    <td><span class="@(p.IsBuy ? "red" : "green")">@p.CurrentTime</span></td>
                    <td>
                        <span>@p.CurrentPrice</span>
                    </td>
                    <td>
                        <span>@p.TradeCount</span>
                    </td>
                    <td>
                        <span>@p.TradeAmount</span>
                    </td>
                    <td>
                        <span class="@(p.IsBuy ? "red" : "green")">@p.FloatPrice</span>
                    </td>
                  
                   
                </tr>
            }
        </tbody>
    </table>
}
<div class="dataTables_paginate paging_bootstrap pagination">
    @Html.Pager(Model, new PagerOptions() { ShowTotalItemCount = true, AutoHide = false })
</div>
<script>
    $(function () {
        $('#tableHistory').dataTable({
            searching: false,
            bFilter: false,
            bLengthChange: false,
            paging: false,
            bInfo: false,
            bPaginate: false,
            "aaSorting": [[1, "desc"]]
        });

        $("#IsBuy").val('@ViewBag.IsBuy');
        $("#btnUpdate").click(function () {
            var t = $("#tableHistory td.blue:first").text();
            $.post("/HistoryData/GetHistoryUpdate", { sharesCodes: t.trim() }, function (data) {
                if (data.status)
                {
                    $("#btnSearch").click();
                }
            });
        });

    });


    String.prototype.trim = function () {

        return this.replace(/(^\s*)|(\s*$)/g, '');
    }
    var dates = $("#BeginDate, #EndDate").datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "+0",
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        onSelect: function (selectedDate) {
            var option = this.id == "startDate" ? "minDate" : "maxDate",
            instance = $(this).data("datepicker"),
            date = $.datepicker.parseDate(
                instance.settings.dateFormat ||
                $.datepicker._defaults.dateFormat,
                selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        }
    });
</script>

